package com.harry.resource.inner.entity;

import javax.persistence.Cacheable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.harry.basis.BasePoEntity;
import static com.harry.configuration.ConstSettings.*;

import lombok.Getter;
import lombok.Setter;

@Cacheable
@Getter
@Setter
@Entity
public class InnerRole extends BasePoEntity {

	private static final long serialVersionUID = 1L;

	@Column(length = MEDIUM_LENGTH)
	private String name;

	@Fetch(FetchMode.JOIN)
	@ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
	@JoinTable(joinColumns = @JoinColumn, inverseJoinColumns = @JoinColumn)
	private Set<InnerUser> users;

	@Fetch(FetchMode.JOIN)
	@ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
	@JoinTable(joinColumns = @JoinColumn, inverseJoinColumns = @JoinColumn)
	private Set<InnerPerm> perms;
}
